import React, { useState } from "react";
import watcher from "@/utils/watcher";

export default function Emitter() {
  const [name, setName] = useState("");
  return (
    <div>
      <input
        value={name}
        onChange={(e) => {
          setName(e.target.value);
        }}
      />
      <button
        onClick={() => {
          if (name) {
            watcher.emit(name);
            setName("");
          }
        }}
      >
        发送
      </button>
    </div>
  );
}
